package org.liu.simpleTank;

public class UpdateContext {
	private long previousTime;
	private long now;
	private int delta;
	boolean needReset;
	{
		needReset = true;
	}
	
	public UpdateContext() {
		previousTime = 0;
		now = 0;
		delta = 0;
	}
	
	/**
	 * this method should only be invoked by Game object to set new updateContext
	 * @param previousTime
	 * @param now
	 * @param delta
	 */
	public void update(long previousTime, long now, int delta) {
		this.previousTime = previousTime;
		this.now = now;
		this.delta = delta;
		if(needReset) {
			this.previousTime = now;
			this.delta = 0;
			needReset = false;
		}
	}
	
	// getters (set up read only restriction)
	public long getPreviousTime() {
		return previousTime;
	}
	public long getNow() {
		return now;
	}
	public int getDelta() {
		return delta;
	}
	
	public void setReset() {
		needReset = true;
	}
}
